package com.foreveross.taskservice.common;


/**
 * 统一的任务状态枚举
 * <p>值在-5到5之间，属于任务定义上的全局状态值，不可更改<br/>
 * 业务自定义状态区间为大于5或小于-5,当接收到的反馈任务状态<-5时，将会转为这里定义的－5，>5时，将会转为这里定义的5
 * @author xiangsf 2014-8-22 
 *
 */
public enum TaskStatusEnum {

	TASK_BUSI_FAIL(-5,"任务业务上定义失败"),
	TASK_OTHER_FAIL(-4,"任务其他失败"),
	TASK_PARSE_FAIL(-3,"任务解析失败"),
	TASK_FETCH_FAIL(-2,"任务抓取失败"),
	TASK_PUBLISH_FAIL(-1,"任务分发失败"),
	TASK_WATI(0,"任务等待中"),
	TASH_PAUSE(1,"任务暂停"),
	TASK_DOING(2,"任务执行中"),
	TASK_SUCCESS(3,"任务成功完成"),
	TASK_UNKOWN(4,"任务状态不明"),//归类于完成后任务状态不明,后继留用
	TASK_BUSI_SUCCESS(5,"任务业务上定义成功");
	
	
	public static TaskStatusEnum getTaskStatusEnum(int status){
		switch(status){
		case 0:
			return TASK_WATI;
		case 1:
			return TASH_PAUSE;
		case 2:
			return TASK_DOING;
		case 3:
			return TASK_SUCCESS;
		case 4:
			return TASK_UNKOWN;
		case 5:
			return TASK_BUSI_SUCCESS;
		case -1:
			return TASK_PUBLISH_FAIL;
		case -2:
			return TASK_FETCH_FAIL;
		case -3:
			return TASK_PARSE_FAIL;
		case -4:
			return TASK_OTHER_FAIL;
		case -5:
			return TASK_BUSI_FAIL;
		default:
			return null;
		}
	}

	private int status;
	private String remake;
	private  TaskStatusEnum(int status,String remake){
		this.status=status;
		this.remake=remake;
	}
	public int getStatus() {
		return status;
	}
	public String getRemake() {
		return remake;
	}
}
